package cn.edu.xust.communication.task;

import cn.edu.xust.configuration.exception.Default200Exception;
import io.github.biezhi.ome.SendMailException;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Lazy;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.scheduling.annotation.Scheduled;

import javax.annotation.PostConstruct;

/**
 * @Author ufo
 * @Description 定时任务
 * @Date 2021/3/1 10:04
 * @Version 1.0
 */


@Slf4j
@EnableScheduling
@Configuration
@Lazy(false)
public class CronTask {


    @Autowired
    TaskList taskList;

    /**
     * 2小时一次 采集所有
     */
//  @PostConstruct
    @Scheduled(cron = "0 0 0/2 * * ?")
    public void readdevicedata() throws Default200Exception, SendMailException {
        taskList.readdevicedata("hour");
    }



    /**
     * 每天凌晨1点30分执行 采集所有
     */
    @Scheduled(cron = "0 30 1 * * ?")
    public void readday() throws Default200Exception, SendMailException {
        taskList.readdevicedata("day");
    }


    /**
     * 每天11.30执行  检查查询情况
     */
    @Scheduled(cron = "0 30 11 * * ?")
    public void check() throws Default200Exception, SendMailException {
        taskList.checkCaiji();
    }

}
